<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - gil/utilities.hpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../index.html">directory</a> - <a href="index.html">gil</a> - utilities.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">9</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">77.8 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">7</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : /*
<span class="lineNum">       2 </span>                :     Copyright 2005-2007 Adobe Systems Incorporated
<span class="lineNum">       3 </span>                :    
<span class="lineNum">       4 </span>                :     Use, modification and distribution are subject to the Boost Software License,
<span class="lineNum">       5 </span>                :     Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       6 </span>                :     http://www.boost.org/LICENSE_1_0.txt).
<span class="lineNum">       7 </span>                : 
<span class="lineNum">       8 </span>                :     See http://opensource.adobe.com/gil for most recent version including documentation.
<span class="lineNum">       9 </span>                : */
<span class="lineNum">      10 </span>                : 
<span class="lineNum">      11 </span>                : /*************************************************************************************************/
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span>                : #ifndef GIL_UTILITIES_H
<span class="lineNum">      14 </span>                : #define GIL_UTILITIES_H
<span class="lineNum">      15 </span>                : 
<span class="lineNum">      16 </span>                : #include &quot;gil_config.hpp&quot;
<span class="lineNum">      17 </span>                : #include &lt;functional&gt;
<span class="lineNum">      18 </span>                : #include &lt;boost/config/no_tr1/cmath.hpp&gt;
<span class="lineNum">      19 </span>                : #include &lt;cstddef&gt;
<span class="lineNum">      20 </span>                : #include &lt;algorithm&gt;
<span class="lineNum">      21 </span>                : #include &lt;utility&gt;
<span class="lineNum">      22 </span>                : #include &lt;iterator&gt;
<span class="lineNum">      23 </span>                : #include &lt;boost/static_assert.hpp&gt;
<span class="lineNum">      24 </span>                : #include &lt;boost/type_traits.hpp&gt;
<span class="lineNum">      25 </span>                : #include &lt;boost/mpl/size.hpp&gt;
<span class="lineNum">      26 </span>                : #include &lt;boost/mpl/distance.hpp&gt;
<span class="lineNum">      27 </span>                : #include &lt;boost/mpl/begin.hpp&gt;
<span class="lineNum">      28 </span>                : #include &lt;boost/mpl/find.hpp&gt;
<span class="lineNum">      29 </span>                : #include &lt;boost/mpl/range_c.hpp&gt;
<span class="lineNum">      30 </span>                : #include &lt;boost/iterator/iterator_adaptor.hpp&gt;
<span class="lineNum">      31 </span>                : #include &lt;boost/iterator/iterator_facade.hpp&gt;
<span class="lineNum">      32 </span>                : 
<span class="lineNum">      33 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      34 </span>                : /// \file               
<span class="lineNum">      35 </span>                : /// \brief  Various utilities not specific to the image library. Some are non-standard STL extensions or generic iterator adaptors
<span class="lineNum">      36 </span>                : /// \author Lubomir Bourdev and Hailin Jin \n
<span class="lineNum">      37 </span>                : ///         Adobe Systems Incorporated
<span class="lineNum">      38 </span>                : /// \date   2005-2007 \n Last updated on September 18, 2007
<span class="lineNum">      39 </span>                : ///
<span class="lineNum">      40 </span>                : ///
<span class="lineNum">      41 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : namespace boost { namespace gil {
<span class="lineNum">      44 </span>                : 
<span class="lineNum">      45 </span>                : /**
<span class="lineNum">      46 </span>                : \addtogroup PointModel
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span>                : Example:
<span class="lineNum">      49 </span>                : \code
<span class="lineNum">      50 </span>                : point2&lt;std::ptrdiff_t&gt; p(3,2);
<span class="lineNum">      51 </span>                : assert((p[0] == p.x) &amp;&amp; (p[1] == p.y));
<span class="lineNum">      52 </span>                : assert(axis_value&lt;0&gt;(p) == 3);
<span class="lineNum">      53 </span>                : assert(axis_value&lt;1&gt;(p) == 2);
<span class="lineNum">      54 </span>                : \endcode
<span class="lineNum">      55 </span>                : */
<span class="lineNum">      56 </span>                : 
<span class="lineNum">      57 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      58 </span>                : //                           CLASS point2
<span class="lineNum">      59 </span>                : ///
<span class="lineNum">      60 </span>                : /// \brief 2D point both axes of which have the same dimension type
<span class="lineNum">      61 </span>                : /// \ingroup PointModel
<span class="lineNum">      62 </span>                : /// Models: Point2DConcept
<span class="lineNum">      63 </span>                : ///
<span class="lineNum">      64 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">      65 </span>                : 
<span class="lineNum">      66 </span>                : template &lt;typename T&gt;
<span class="lineNum">      67 </span>                : class point2 {
<span class="lineNum">      68 </span>                : public:
<span class="lineNum">      69 </span>                :     typedef T value_type;
<span class="lineNum">      70 </span>                :     template &lt;std::size_t D&gt; struct axis { typedef value_type coord_t; };
<span class="lineNum">      71 </span>                :     static const std::size_t num_dimensions=2;
<span class="lineNum">      72 </span>                : 
<span class="lineNum">      73 </span><span class="lineCov">              7 :     point2()                : x(0),     y(0)    {}</span>
<span class="lineNum">      74 </span><span class="lineCov">            133 :     point2(T newX, T newY)  : x(newX),  y(newY) {}</span>
<span class="lineNum">      75 </span><span class="lineCov">            113 :     point2(const point2&amp; p) : x(p.x), y(p.y) {}</span>
<span class="lineNum">      76 </span><span class="lineCov">            250 :     ~point2() {}</span>
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span><span class="lineCov">             65 :     point2&amp; operator=(const point2&amp; p)            { x=p.x; y=p.y; return *this; }</span>
<span class="lineNum">      79 </span>                : 
<span class="lineNum">      80 </span>                :     point2        operator&lt;&lt;(std::ptrdiff_t shift)         const   { return point2(x&lt;&lt;shift,y&lt;&lt;shift); }
<span class="lineNum">      81 </span>                :     point2        operator&gt;&gt;(std::ptrdiff_t shift)         const   { return point2(x&gt;&gt;shift,y&gt;&gt;shift); }
<span class="lineNum">      82 </span>                :     point2&amp; operator+=(const point2&amp; p)           { x+=p.x; y+=p.y; return *this; }
<span class="lineNum">      83 </span>                :     point2&amp; operator-=(const point2&amp; p)           { x-=p.x; y-=p.y; return *this; }
<span class="lineNum">      84 </span>                :     point2&amp; operator/=(double t)                  { x/=t; y/=t; return *this; }
<span class="lineNum">      85 </span>                : 
<span class="lineNum">      86 </span>                :     const T&amp; operator[](std::size_t i)          const   { return this-&gt;*mem_array[i]; }
<span class="lineNum">      87 </span>                :           T&amp; operator[](std::size_t i)                  { return this-&gt;*mem_array[i]; }
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span>                :     T x,y;
<span class="lineNum">      90 </span>                : private:
<span class="lineNum">      91 </span>                :     // this static array of pointers to member variables makes operator[] safe and doesn't seem to exhibit any performance penalty
<span class="lineNum">      92 </span>                :     static T point2&lt;T&gt;::* const mem_array[num_dimensions];
<span class="lineNum">      93 </span>                : };
<span class="lineNum">      94 </span>                : 
<span class="lineNum">      95 </span>                : template &lt;typename T&gt;
<span class="lineNum">      96 </span>                : T point2&lt;T&gt;::* const point2&lt;T&gt;::mem_array[point2&lt;T&gt;::num_dimensions] = { &amp;point2&lt;T&gt;::x, &amp;point2&lt;T&gt;::y };
<span class="lineNum">      97 </span>                : 
<span class="lineNum">      98 </span>                : /// \ingroup PointModel
<span class="lineNum">      99 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     100 </span><span class="lineCov">             14 : bool operator==(const point2&lt;T&gt;&amp; p1, const point2&lt;T&gt;&amp; p2) { return (p1.x==p2.x &amp;&amp; p1.y==p2.y); }</span>
<span class="lineNum">     101 </span>                : /// \ingroup PointModel
<span class="lineNum">     102 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     103 </span><span class="lineCov">             13 : bool operator!=(const point2&lt;T&gt;&amp; p1, const point2&lt;T&gt;&amp; p2) { return  p1.x!=p2.x || p1.y!=p2.y; }</span>
<span class="lineNum">     104 </span>                : /// \ingroup PointModel
<span class="lineNum">     105 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     106 </span>                : point2&lt;T&gt; operator+(const point2&lt;T&gt;&amp; p1, const point2&lt;T&gt;&amp; p2) { return point2&lt;T&gt;(p1.x+p2.x,p1.y+p2.y); }
<span class="lineNum">     107 </span>                : /// \ingroup PointModel
<span class="lineNum">     108 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     109 </span>                : point2&lt;T&gt; operator-(const point2&lt;T&gt;&amp; p) { return point2&lt;T&gt;(-p.x,-p.y); }
<span class="lineNum">     110 </span>                : /// \ingroup PointModel
<span class="lineNum">     111 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     112 </span>                : point2&lt;T&gt; operator-(const point2&lt;T&gt;&amp; p1, const point2&lt;T&gt;&amp; p2) { return point2&lt;T&gt;(p1.x-p2.x,p1.y-p2.y); }
<span class="lineNum">     113 </span>                : /// \ingroup PointModel
<span class="lineNum">     114 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     115 </span>                : point2&lt;double&gt; operator/(const point2&lt;T&gt;&amp; p, double t)      { return t==0 ? point2&lt;double&gt;(0,0):point2&lt;double&gt;(p.x/t,p.y/t); }
<span class="lineNum">     116 </span>                : /// \ingroup PointModel
<span class="lineNum">     117 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     118 </span>                : point2&lt;T&gt; operator*(const point2&lt;T&gt;&amp; p, std::ptrdiff_t t)      { return point2&lt;T&gt;(p.x*t,p.y*t); }
<span class="lineNum">     119 </span>                : /// \ingroup PointModel
<span class="lineNum">     120 </span>                : template &lt;typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     121 </span>                : point2&lt;T&gt; operator*(std::ptrdiff_t t, const point2&lt;T&gt;&amp; p)      { return point2&lt;T&gt;(p.x*t,p.y*t); }
<span class="lineNum">     122 </span>                : 
<span class="lineNum">     123 </span>                : /// \ingroup PointModel
<span class="lineNum">     124 </span>                : template &lt;std::size_t K, typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     125 </span>                : const T&amp; axis_value(const point2&lt;T&gt;&amp; p) { return p[K]; }
<span class="lineNum">     126 </span>                : 
<span class="lineNum">     127 </span>                : /// \ingroup PointModel
<span class="lineNum">     128 </span>                : template &lt;std::size_t K, typename T&gt; GIL_FORCEINLINE
<span class="lineNum">     129 </span>                :       T&amp; axis_value(      point2&lt;T&gt;&amp; p) { return p[K]; }
<span class="lineNum">     130 </span>                : 
<span class="lineNum">     131 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">     132 </span>                : ///
<span class="lineNum">     133 </span>                : ///  Rounding of real numbers / points to integers / integer points
<span class="lineNum">     134 </span>                : ///
<span class="lineNum">     135 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">     136 </span>                : 
<span class="lineNum">     137 </span>                : inline std::ptrdiff_t iround(float x ) { return static_cast&lt;std::ptrdiff_t&gt;(x + (x &lt; 0.0f ? -0.5f : 0.5f)); }
<span class="lineNum">     138 </span>                : inline std::ptrdiff_t iround(double x) { return static_cast&lt;std::ptrdiff_t&gt;(x + (x &lt; 0.0 ? -0.5 : 0.5)); }
<span class="lineNum">     139 </span>                : inline std::ptrdiff_t ifloor(float x ) { return static_cast&lt;std::ptrdiff_t&gt;(std::floor(x)); }
<span class="lineNum">     140 </span>                : inline std::ptrdiff_t ifloor(double x) { return static_cast&lt;std::ptrdiff_t&gt;(std::floor(x)); }
<span class="lineNum">     141 </span>                : inline std::ptrdiff_t iceil(float x )  { return static_cast&lt;std::ptrdiff_t&gt;(std::ceil(x)); }
<span class="lineNum">     142 </span>                : inline std::ptrdiff_t iceil(double x)  { return static_cast&lt;std::ptrdiff_t&gt;(std::ceil(x)); }
<span class="lineNum">     143 </span>                : 
<span class="lineNum">     144 </span>                : /**
<span class="lineNum">     145 </span>                : \addtogroup PointAlgorithm
<span class="lineNum">     146 </span>                : 
<span class="lineNum">     147 </span>                : Example:
<span class="lineNum">     148 </span>                : \code
<span class="lineNum">     149 </span>                : assert(iround(point2&lt;double&gt;(3.1, 3.9)) == point2&lt;std::ptrdiff_t&gt;(3,4));
<span class="lineNum">     150 </span>                : \endcode
<span class="lineNum">     151 </span>                : */
<span class="lineNum">     152 </span>                : 
<span class="lineNum">     153 </span>                : /// \ingroup PointAlgorithm
<span class="lineNum">     154 </span>                : inline point2&lt;std::ptrdiff_t&gt; iround(const point2&lt;float &gt;&amp; p)  { return point2&lt;std::ptrdiff_t&gt;(iround(p.x),iround(p.y)); }
<span class="lineNum">     155 </span>                : /// \ingroup PointAlgorithm
<span class="lineNum">     156 </span>                : inline point2&lt;std::ptrdiff_t&gt; iround(const point2&lt;double&gt;&amp; p)  { return point2&lt;std::ptrdiff_t&gt;(iround(p.x),iround(p.y)); }
<span class="lineNum">     157 </span>                : /// \ingroup PointAlgorithm
<span class="lineNum">     158 </span>                : inline point2&lt;std::ptrdiff_t&gt; ifloor(const point2&lt;float &gt;&amp; p)  { return point2&lt;std::ptrdiff_t&gt;(ifloor(p.x),ifloor(p.y)); }
<span class="lineNum">     159 </span>                : /// \ingroup PointAlgorithm
<span class="lineNum">     160 </span>                : inline point2&lt;std::ptrdiff_t&gt; ifloor(const point2&lt;double&gt;&amp; p)  { return point2&lt;std::ptrdiff_t&gt;(ifloor(p.x),ifloor(p.y)); }
<span class="lineNum">     161 </span>                : /// \ingroup PointAlgorithm
<span class="lineNum">     162 </span>                : inline point2&lt;std::ptrdiff_t&gt; iceil (const point2&lt;float &gt;&amp; p)  { return point2&lt;std::ptrdiff_t&gt;(iceil(p.x), iceil(p.y)); }
<span class="lineNum">     163 </span>                : /// \ingroup PointAlgorithm
<span class="lineNum">     164 </span>                : inline point2&lt;std::ptrdiff_t&gt; iceil (const point2&lt;double&gt;&amp; p)  { return point2&lt;std::ptrdiff_t&gt;(iceil(p.x), iceil(p.y)); }
<span class="lineNum">     165 </span>                : 
<span class="lineNum">     166 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">     167 </span>                : ///
<span class="lineNum">     168 </span>                : ///  computing size with alignment
<span class="lineNum">     169 </span>                : ///
<span class="lineNum">     170 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">     171 </span>                : 
<span class="lineNum">     172 </span>                : template &lt;typename T&gt; 
<span class="lineNum">     173 </span><span class="lineNoCov">              0 : inline T align(T val, std::size_t alignment) { </span>
<span class="lineNum">     174 </span><span class="lineNoCov">              0 :     return val+(alignment - val%alignment)%alignment; </span>
<span class="lineNum">     175 </span>                : }
<span class="lineNum">     176 </span>                : 
<span class="lineNum">     177 </span>                : /// \brief Helper base class for pixel dereference adaptors. 
<span class="lineNum">     178 </span>                : /// \ingroup PixelDereferenceAdaptorModel
<span class="lineNum">     179 </span>                : ///
<span class="lineNum">     180 </span>                : template &lt;typename ConstT, typename Value, typename Reference, typename ConstReference,
<span class="lineNum">     181 </span>                :           typename ArgType, typename ResultType, bool IsMutable&gt;
<span class="lineNum">     182 </span>                : struct deref_base : public std::unary_function&lt;ArgType, ResultType&gt; {
<span class="lineNum">     183 </span>                :     typedef ConstT         const_t;
<span class="lineNum">     184 </span>                :     typedef Value          value_type;
<span class="lineNum">     185 </span>                :     typedef Reference      reference;
<span class="lineNum">     186 </span>                :     typedef ConstReference const_reference;
<span class="lineNum">     187 </span>                :     BOOST_STATIC_CONSTANT(bool, is_mutable = IsMutable);
<span class="lineNum">     188 </span>                : };
<span class="lineNum">     189 </span>                : 
<span class="lineNum">     190 </span>                : /// \brief Composes two dereference function objects. Similar to std::unary_compose but needs to pull some typedefs from the component types.  Models: PixelDereferenceAdaptorConcept
<span class="lineNum">     191 </span>                : /// \ingroup PixelDereferenceAdaptorModel
<span class="lineNum">     192 </span>                : ///
<span class="lineNum">     193 </span>                : template &lt;typename D1, typename D2&gt;
<span class="lineNum">     194 </span>                : class deref_compose : public deref_base&lt;
<span class="lineNum">     195 </span>                :       deref_compose&lt;typename D1::const_t, typename D2::const_t&gt;,
<span class="lineNum">     196 </span>                :       typename D1::value_type, typename D1::reference, typename D1::const_reference, 
<span class="lineNum">     197 </span>                :       typename D2::argument_type, typename D1::result_type, D1::is_mutable &amp;&amp; D2::is_mutable&gt;
<span class="lineNum">     198 </span>                : {
<span class="lineNum">     199 </span>                : public:
<span class="lineNum">     200 </span>                :     D1 _fn1;
<span class="lineNum">     201 </span>                :     D2 _fn2;
<span class="lineNum">     202 </span>                : 
<span class="lineNum">     203 </span>                :     typedef typename D2::argument_type   argument_type;
<span class="lineNum">     204 </span>                :     typedef typename D1::result_type     result_type;
<span class="lineNum">     205 </span>                : 
<span class="lineNum">     206 </span>                :     deref_compose() {}
<span class="lineNum">     207 </span>                :     deref_compose(const D1&amp; x, const D2&amp; y) : _fn1(x), _fn2(y) {}
<span class="lineNum">     208 </span>                :     deref_compose(const deref_compose&amp; dc)  : _fn1(dc._fn1), _fn2(dc._fn2) {}
<span class="lineNum">     209 </span>                :     template &lt;typename _D1, typename _D2&gt; deref_compose(const deref_compose&lt;_D1,_D2&gt;&amp; dc) : _fn1(dc._fn1), _fn2(dc._fn2) {}
<span class="lineNum">     210 </span>                : 
<span class="lineNum">     211 </span>                :     result_type operator()(argument_type x) const { return _fn1(_fn2(x)); }
<span class="lineNum">     212 </span>                :     result_type operator()(argument_type x)       { return _fn1(_fn2(x)); }
<span class="lineNum">     213 </span>                : };
<span class="lineNum">     214 </span>                : 
<span class="lineNum">     215 </span>                : // reinterpret_cast is implementation-defined. Static cast is not.
<span class="lineNum">     216 </span>                : template &lt;typename OutPtr, typename In&gt; GIL_FORCEINLINE
<span class="lineNum">     217 </span>                :       OutPtr gil_reinterpret_cast(      In* p) { return static_cast&lt;OutPtr&gt;(static_cast&lt;void*&gt;(p)); }
<span class="lineNum">     218 </span>                : 
<span class="lineNum">     219 </span>                : template &lt;typename OutPtr, typename In&gt; GIL_FORCEINLINE
<span class="lineNum">     220 </span>                : const OutPtr gil_reinterpret_cast_c(const In* p) { return static_cast&lt;const OutPtr&gt;(static_cast&lt;const void*&gt;(p)); }
<span class="lineNum">     221 </span>                : 
<span class="lineNum">     222 </span>                : namespace detail {
<span class="lineNum">     223 </span>                : 
<span class="lineNum">     224 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">     225 </span>                : ///
<span class="lineNum">     226 </span>                : ///  \brief copy_n taken from SGI STL.
<span class="lineNum">     227 </span>                : ///
<span class="lineNum">     228 </span>                : ////////////////////////////////////////////////////////////////////////////////////////
<span class="lineNum">     229 </span>                : 
<span class="lineNum">     230 </span>                : template &lt;class InputIter, class Size, class OutputIter&gt;
<span class="lineNum">     231 </span>                : std::pair&lt;InputIter, OutputIter&gt; _copy_n(InputIter first, Size count,
<span class="lineNum">     232 </span>                :                                          OutputIter result,
<span class="lineNum">     233 </span>                :                                          std::input_iterator_tag) {
<span class="lineNum">     234 </span>                :    for ( ; count &gt; 0; --count) {
<span class="lineNum">     235 </span>                :       *result = *first;
<span class="lineNum">     236 </span>                :       ++first;
<span class="lineNum">     237 </span>                :       ++result;
<span class="lineNum">     238 </span>                :    }
<span class="lineNum">     239 </span>                :    return std::pair&lt;InputIter, OutputIter&gt;(first, result);
<span class="lineNum">     240 </span>                : }
<span class="lineNum">     241 </span>                : 
<span class="lineNum">     242 </span>                : template &lt;class RAIter, class Size, class OutputIter&gt;
<span class="lineNum">     243 </span>                : inline std::pair&lt;RAIter, OutputIter&gt;
<span class="lineNum">     244 </span>                : _copy_n(RAIter first, Size count, OutputIter result, std::random_access_iterator_tag) {
<span class="lineNum">     245 </span>                :    RAIter last = first + count;
<span class="lineNum">     246 </span>                :    return std::pair&lt;RAIter, OutputIter&gt;(last, std::copy(first, last, result));
<span class="lineNum">     247 </span>                : }
<span class="lineNum">     248 </span>                : 
<span class="lineNum">     249 </span>                : template &lt;class InputIter, class Size, class OutputIter&gt;
<span class="lineNum">     250 </span>                : inline std::pair&lt;InputIter, OutputIter&gt;
<span class="lineNum">     251 </span>                : _copy_n(InputIter first, Size count, OutputIter result) {
<span class="lineNum">     252 </span>                :    return _copy_n(first, count, result, typename std::iterator_traits&lt;InputIter&gt;::iterator_category());
<span class="lineNum">     253 </span>                : }
<span class="lineNum">     254 </span>                : 
<span class="lineNum">     255 </span>                : template &lt;class InputIter, class Size, class OutputIter&gt;
<span class="lineNum">     256 </span>                : inline std::pair&lt;InputIter, OutputIter&gt;
<span class="lineNum">     257 </span>                : copy_n(InputIter first, Size count, OutputIter result) {
<span class="lineNum">     258 </span>                :     return detail::_copy_n(first, count, result);
<span class="lineNum">     259 </span>                : }
<span class="lineNum">     260 </span>                : 
<span class="lineNum">     261 </span>                : /// \brief identity taken from SGI STL.
<span class="lineNum">     262 </span>                : template &lt;typename T&gt; 
<span class="lineNum">     263 </span>                : struct identity : public std::unary_function&lt;T,T&gt; {
<span class="lineNum">     264 </span>                :     const T&amp; operator()(const T&amp; val) const { return val; }
<span class="lineNum">     265 </span>                : };
<span class="lineNum">     266 </span>                : 
<span class="lineNum">     267 </span>                : /*************************************************************************************************/
<span class="lineNum">     268 </span>                : 
<span class="lineNum">     269 </span>                : /// \brief plus function object whose arguments may be of different type.
<span class="lineNum">     270 </span>                : template &lt;typename T1, typename T2&gt;
<span class="lineNum">     271 </span>                : struct plus_asymmetric : public std::binary_function&lt;T1,T2,T1&gt; {
<span class="lineNum">     272 </span>                :     T1 operator()(T1 f1, T2 f2) const {
<span class="lineNum">     273 </span>                :         return f1+f2;
<span class="lineNum">     274 </span>                :     }
<span class="lineNum">     275 </span>                : };
<span class="lineNum">     276 </span>                : 
<span class="lineNum">     277 </span>                : /*************************************************************************************************/
<span class="lineNum">     278 </span>                : 
<span class="lineNum">     279 </span>                : /// \brief operator++ wrapped in a function object
<span class="lineNum">     280 </span>                : template &lt;typename T&gt;
<span class="lineNum">     281 </span>                : struct inc : public std::unary_function&lt;T,T&gt; {
<span class="lineNum">     282 </span>                :     T operator()(T x) const { return ++x; }
<span class="lineNum">     283 </span>                : };
<span class="lineNum">     284 </span>                : 
<span class="lineNum">     285 </span>                : /*************************************************************************************************/
<span class="lineNum">     286 </span>                : 
<span class="lineNum">     287 </span>                : /// \brief operator-- wrapped in a function object
<span class="lineNum">     288 </span>                : template &lt;typename T&gt;
<span class="lineNum">     289 </span>                : struct dec : public std::unary_function&lt;T,T&gt; {
<span class="lineNum">     290 </span>                :     T operator()(T x) const { return --x; }
<span class="lineNum">     291 </span>                : };
<span class="lineNum">     292 </span>                : 
<span class="lineNum">     293 </span>                : /// \brief Returns the index corresponding to the first occurrance of a given given type in 
<span class="lineNum">     294 </span>                : //         a given MPL RandomAccessSequence (or size if the type is not present)
<span class="lineNum">     295 </span>                : template &lt;typename Types, typename T&gt;
<span class="lineNum">     296 </span>                : struct type_to_index 
<span class="lineNum">     297 </span>                :     : public mpl::distance&lt;typename mpl::begin&lt;Types&gt;::type, 
<span class="lineNum">     298 </span>                :                                   typename mpl::find&lt;Types,T&gt;::type&gt;::type {};
<span class="lineNum">     299 </span>                : } // namespace detail
<span class="lineNum">     300 </span>                : 
<span class="lineNum">     301 </span>                : 
<span class="lineNum">     302 </span>                : 
<span class="lineNum">     303 </span>                : /// \ingroup ColorSpaceAndLayoutModel
<span class="lineNum">     304 </span>                : /// \brief Represents a color space and ordering of channels in memory
<span class="lineNum">     305 </span>                : template &lt;typename ColorSpace, typename ChannelMapping = mpl::range_c&lt;int,0,mpl::size&lt;ColorSpace&gt;::value&gt; &gt;
<span class="lineNum">     306 </span>                : struct layout {
<span class="lineNum">     307 </span>                :     typedef ColorSpace      color_space_t;
<span class="lineNum">     308 </span>                :     typedef ChannelMapping  channel_mapping_t;
<span class="lineNum">     309 </span>                : };
<span class="lineNum">     310 </span>                : 
<span class="lineNum">     311 </span>                : /// \brief A version of swap that also works with reference proxy objects
<span class="lineNum">     312 </span>                : template &lt;typename Value, typename T1, typename T2&gt; // where value_type&lt;T1&gt;  == value_type&lt;T2&gt; == Value
<span class="lineNum">     313 </span>                : void swap_proxy(T1&amp; left, T2&amp; right) {
<span class="lineNum">     314 </span>                :     Value tmp = left;
<span class="lineNum">     315 </span>                :     left = right;
<span class="lineNum">     316 </span>                :     right = tmp;
<span class="lineNum">     317 </span>                : }
<span class="lineNum">     318 </span>                : 
<span class="lineNum">     319 </span>                : /// \brief Run-time detection of whether the underlying architecture is little endian
<span class="lineNum">     320 </span>                : inline bool little_endian() {
<span class="lineNum">     321 </span>                :     short tester = 0x0001;
<span class="lineNum">     322 </span>                :     return  *(char*)&amp;tester!=0;
<span class="lineNum">     323 </span>                : }
<span class="lineNum">     324 </span>                : /// \brief Run-time detection of whether the underlying architecture is big endian
<span class="lineNum">     325 </span>                : inline bool big_endian() {
<span class="lineNum">     326 </span>                :     return !little_endian();
<span class="lineNum">     327 </span>                : }
<span class="lineNum">     328 </span>                : 
<span class="lineNum">     329 </span>                : } }  // namespace boost::gil
<span class="lineNum">     330 </span>                : 
<span class="lineNum">     331 </span>                : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
